﻿using SqlSugar;
namespace Model
{
    public class Product
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
        public int Id { get; set; }
        public string Name { get; set; }
        public string CharacterCode { get; set; }
        public int Length { get; set; }

        public int CCodeLength { get; set; }

        public int CCodeLocation { get; set; }

       

        public Product()
        {
            Name = string.Empty;
            CharacterCode = string.Empty;
        }
        /// <summary>
        /// 检查code是否符合特征要求
        /// </summary>
        /// <param name="code"></param>
        /// <returns></returns>
        public bool Check(string code)
        {
            if (code.Length == Length && code.Substring(CCodeLocation, CCodeLength) == CharacterCode)
                return true;
            return false;
        }

    }
}